import { getTreeList } from "@/api/role";
export const operateList = [
  {
    name: $i18n.t("common.add"),
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "add", //点击时返回的标识
    auth: "auth:role:add", //权限字段
  },
];
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit", //点击时返回的标识
    auth: "auth:role:edit", //权限字段
  },
  {
    name: $i18n.t("role.allocateResources"),
    type: "success",
    class: "row-btn-success",
    handleName: "resources", //点击时返回的标识
    auth: "auth:role:resources", //权限字段
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete", //点击时返回的标识
    auth: "auth:role:delete", //权限字段
  },
];
export const formConfig = {
  inline: true,
  formDesc: {
    roleCode: {
      type: "input",
      label: $i18n.t("role.roleCode"),
    },
    roleName: {
      type: "input",
      label: $i18n.t("role.roleName"),
    },
    status: {
      type: "select",
      label: $i18n.t("role.status"),
      options: [
        {
          text: $i18n.t("role.normal"),
          value: "0",
        },
        {
          text: $i18n.t("role.stopUsing"),
          value: "1",
        },
      ],
    },
    date: {
      type: "daterange",
      label: $i18n.t("home.tableColumn.createTime"),
      attrs: {
        "value-format": "yyyy-MM-dd",
        searchArrKey: ["startDate", "endDate"], //配置把值 返给数组内字段
      },
    },
  },
};
export const formDescDialogUp = {
  span: 24,
  formDesc: {
    roleCode: {
      type: "input",
      label: $i18n.t("role.roleCode"),
      layout: 12,
      required: true,
    },
    roleName: {
      type: "input",
      label: $i18n.t("role.roleName"),
      layout: 12,
      required: true,
    },
    // roleSort: {
    //   type: 'number',
    //   label: $i18n.t('role.sort'),
    //   layout: 12,
    //   attrs: {
    //     min: 0,
    //     'controls-position': 'right'
    //   },
    //   required: true
    // },
    status: {
      type: "select",
      label: $i18n.t("user.status"),
      required: true,
      layout: 12,
      options: (data) => {
        return [
          {
            text: $i18n.t("role.normal"),
            value: "0",
          },
          {
            text: $i18n.t("role.stopUsing"),
            value: "1",
          },
        ];
      },
    },
  },
};

export const sourcesDialogre = {
  span: 24,
  formDesc: {
    roleCode: {
      type: "input",
      label: $i18n.t("role.roleCode"),
      layout: 12,
      disabled: true,
    },
    roleName: {
      type: "input",
      disabled: true,
      label: $i18n.t("role.roleName"),
      layout: 12,
    },
    resourceIds: {
      type: "tree-select",
      label: $i18n.t("role.resources"),
      layout: 24,
      required: true,
      attrs: {
        "value-consists-of": "ALL_WITH_INDETERMINATE",
        limit: 4,
        multiple: true,
        normalizer(node) {
          return {
            id: node.id,
            label: node.name,
            children: node.children,
          };
        },
      },
      options: [],
      // options: async (data) => {
      //   const list = await getTreeList();
      //   return [
      //     {
      //       label: "不1212错",
      //       name: "测试name",
      //       id: 111,
      //       children: [],
      //       isDisabled: true,
      //     },
      //     ...list.data.result,
      //   ];
      // },
    },
  },
};
